package com.sky.controller.admin;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.ReportDto;
import com.sky.result.Result;
import com.sky.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.Get;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;

/**
 * @ClassName: ReportController
 * @Author: YuanDing
 * @Date: 2024/2/9 16:22
 * @Description:
 */

@Api(tags = "数据统计相关")
@RestController
@RequestMapping("/admin/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @ApiOperation("订单统计接口")
    @GetMapping("/ordersStatistics")
    public Result ordersStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin , @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
        Result result = reportService.ordersStatistics(begin , end);
        return result;
    }

    @ApiOperation("营业额统计")
    @GetMapping("/turnoverStatistics")
    public Result turnoverStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin , @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end) {
        Result result = reportService.turnoverStatistics(begin , end);
        return result;
    }

    @ApiOperation("销量TOP10")
    @GetMapping("/top10")
    public Result top(ReportDto reportDto) {
        Result result = reportService.top(reportDto);
        return result;
    }

    @ApiOperation("用户统计")
    @GetMapping("/userStatistics")
    public Result userStatistics(ReportDto reportDto) {
        Result result = reportService.userStatistics(reportDto);
        return result;
    }

    @ApiOperation("导出Excel报表接口")
    @GetMapping("/export")
    public void export(HttpServletResponse httpServletResponse) {
        reportService.export(httpServletResponse);
    }
}
